﻿using _01_登录界面.Common;
using _01_登录界面.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace _01_登录界面.ViewModel
{
	public class MainViewModel:NotifyBase
	{
		public UserModel UserInfo { get; set; } = new UserModel();

		private string _searchText;

		public string SearchText
		{
			get 
			{
				return _searchText; 
			} 
			set
			{
				_searchText = value;
				Changed();
							}
		}
		private FrameworkElement _mainContent;
		public FrameworkElement MainContent
		{
			get { return _mainContent; }
			set { _mainContent = value;Changed();  }
		}

		public CommandBase NavChangeCommand { get; set; }
		public MainViewModel()
		{
			NavChangeCommand = new CommandBase();
			NavChangeCommand.DoCanExcute = new Func<object, bool>((o) => true);
			NavChangeCommand.DoExcute = new Action<object>(DoNavChanged);
			DoNavChanged("FirstPageView");
		}

		private void DoNavChanged(object obj)
		{
			Type type = Type.GetType("_01_登录界面.View." + obj.ToString());
			ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
			this.MainContent = (FrameworkElement)cti.Invoke(null);
		}
	}
}
